#include<iostream>
using namespace std;
int C[202][202] = { 0 };
int MatchChain(int n,int* r)
{
	int d;
	for (d = 1; d < n; d++)
	{
		int i = 0;
		for (i = 0; i < n-d; i++)
		{
			   int j=i+d;			
				C[i][j] = 10e9;
				int k;
				for (k = i + 1; k <= j; k++)
				{
					C[i][j] = min(C[i][j], C[i][k - 1] + C[k][j] + r[2*i] * r[2*j+1 ] * r[2*k]);
				}
			
		}
	}
	return C[0][n - 1];
}
int main()
{
	int n,i;
	cin >> n;
	int* r = new int[2*n];
	for (i = 0; i <2* n; i+=2)
	{
		int x, y;
		cin >> x >> y;
		r[i] = x;
		r[i + 1] = y;
	}
	cout<<MatchChain(n,r);
}